import { createRouter, createWebHashHistory, RouteRecordRaw } from "vue-router";
// import { useMainStore } from "@/store/index";

const routes: Array<RouteRecordRaw> = [
  {
    path: "/home",
    name: "home",
    component: () =>
      import(/* webpackChunkName: "about" */ "../views/HomeView.vue"),
  },
  {
    path: "/",
    redirect: "/home",
  },
  {
    path: "/login",
    name: "LoginView",
    component: () =>
      import(/* webpackChunkName: "about" */ "../views/LoginView.vue"),
  },
  {
    path: "/setting",
    name: "SettingView",
    component: () =>
      import(/* webpackChunkName: "about" */ "../views/SettingView.vue"),
  },
  {
    path: "/about",
    name: "about",
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () =>
      import(/* webpackChunkName: "about" */ "../views/AboutView.vue"),
  },
];

// const store = useMainStore();
const router = createRouter({
  history: createWebHashHistory(),
  routes,
});

// router.beforeEach((to, from) => {
//   if (to.path === "/") {
//     store.state.open = true;
//   } else {
//     store.state.open = false;
//   }
// });

export default router;
